//
//  DrawerView.m
//  美食百科
//
//  Created by dllo on 16/1/22.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "DrawerView.h"
@interface DrawerView()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,retain)UITableView *drawerTableView;
@property(nonatomic,retain)NSArray *picArray;
@property(nonatomic,retain)NSArray *titleArray;

@end
@implementation DrawerView
- (void)dealloc
{
    [_drawerTableView release];
    [_picArray release];
    [_titleArray release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       // NSLog(@"🍊");
        self.picArray = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7"];
        self.titleArray = @[@"类别",@"烹饪方式",@"品牌",@"连锁餐饮",@"季节",@"视频教程",@"更多"];
        [self createTableView];
    }
    return self;
}

-(void)createTableView{
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.bounds];
        imageView.image = [UIImage imageNamed:@"u=47325509,866348074&fm=21&gp=0"];
        [self addSubview:imageView];
        [imageView release];
        self.drawerTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, self.bounds.size.height/10, self.bounds.size.width, self.bounds.size.height) style:UITableViewStyleGrouped];
        self.drawerTableView.dataSource = self;
        self.drawerTableView.delegate = self;
        self.drawerTableView.backgroundColor = [UIColor clearColor];
        self.drawerTableView.scrollEnabled = NO;
    self.drawerTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
        [self addSubview:self.drawerTableView];
    
        [_drawerTableView release];
        [self.drawerTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"drawerCell"];
   // NSLog(@"🍎");
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{  // NSLog(@"🍑");
    return self.picArray.count;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"drawerCell"];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor =  [UIColor whiteColor];
    cell.textLabel.font = [UIFont systemFontOfSize:16];
;
    
  cell.imageView.image =[UIImage imageNamed:self.picArray[indexPath.row]];
            cell.textLabel.text = self.titleArray[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

            return cell;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [UIScreen mainScreen].bounds.size.height/13;
   
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.block(indexPath);
}


@end
